﻿using System.Web.Mvc;
using Unijovem.Domain;
using Unijovem.UI.Models;
using System.Collections.Generic;
using System.Linq;

namespace Unijovem.UI.Controllers
{
    public class EventoMusicaController : ControllerBase<EventoMusicaModel, EventoMusica>
    {
        public ActionResult Associar(int idEvento)
        {
            PreencherViewBags();
            return View(new EventoMusicaModel { IdEvento = idEvento });
        }
        [HttpPost]
        public ActionResult Associar(EventoMusicaModel model)
        {
            return Criar(model);
        }

        public void PreencherViewBags(int? idMusica = null)
        {
            ViewBag.Musicas = new Musica().SelectAllActive<Musica>().OrderBy(m => m.Titulo).
                ToSelectList(g => string.Concat(g.Titulo, " - ", g.Autor.Nome), g => g.Id.ToString(), "Musica", idMusica.ToString());
        }
    }
}
